﻿using System.Collections.Generic;
using JLL.China.Infrastructure.Repositories;
using JLL.China.Infrastructure.Repositories.ProjectDirFloorPlan;
using JLL.China.Infrastructure.RepositoryFramework;

namespace JLL.China.Infrastructure.Services
{
    public static class PrjDirFlrPlanService
    {
        private static PrjDirFlrPlanRepository repository;
        static PrjDirFlrPlanService()
        {
            repository = RepositoryFactory.GetRepository<PrjDirFlrPlanRepository, Model.ProjectDirFloorPlan, int>(new LINQ2SQLUnitOfWork<int>());
        }
        public static int Deleted(decimal? id)
        {
            return repository.Deleted(id);
        }
        public static decimal Create(Model.ProjectDirFloorPlan prj, Model.ProjectDirFloorPlan prjLocal)
        {
            prj.LanguageFID = 1;
            decimal id = repository.Create(prj);
            prjLocal.LanguageFID = 2;
            prjLocal.NoUnit = prj.NoUnit;
            prjLocal.ListingFID = prj.ListingFID;
            prjLocal.FloorPlanImg = prj.FloorPlanImg;
            prjLocal.ProjectDirFloorPlan_ID = id;
            return repository.Create(prjLocal);
        }

        public static decimal Update(Model.ProjectDirFloorPlan prj, Model.ProjectDirFloorPlan prjLocal)
        {
            prj.LanguageFID = 1;
            prjLocal.LanguageFID = 2;
            prjLocal.NoUnit = prj.NoUnit;
            prjLocal.ListingFID = prj.ListingFID;
            prjLocal.FloorPlanImg = prj.FloorPlanImg;
            prjLocal.ProjectDirFloorPlan_ID = prj.ProjectDirFloorPlan_ID;
            repository.Update(prj);
            return repository.Update(prjLocal);
        }

        public static IList<Model.ProjectDirFloorPlan> FindByListingID_Language(decimal? listingid,decimal languagefid)
        {
            var result= repository.FindByListingID_Language(listingid, languagefid);
            return result;
        }

        public static Model.ProjectDirFloorPlan FindByID_Language(decimal? ID, decimal languageFID)
        {
            var result = repository.FindByID_Language(ID, languageFID);
            return result;
        }
    }
}
